package com.coda.controller;

import com.coda.entity.FacilityInfo;
import com.coda.result.Result;
import com.coda.service.FacilityService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/admin/facility")
@Api(tags = "配套管理")
public class FacilityController {
    @Autowired
    private FacilityService facilityService;

    /**
     * 新增或修改配套信息
     */
    @PostMapping("/saveOrUpdate")
    @ApiOperation("新增或修改配套信息")
    public Result saveOrUpdate(@RequestBody FacilityInfo facilityInfo){
        facilityService.saveOrUpdate(facilityInfo);
        return Result.ok();
    }
    /**
     * 查询配套信息列表
     */
    @GetMapping("/list")
    @ApiOperation(value = "查询配套信息列表")
    public Result<List<FacilityInfo>> getFacilityList(){
        List<FacilityInfo> facilityInfos = facilityService.getFacilityList();
        return Result.ok(facilityInfos);
    }
    /**
     *根据删除配套信息
     */
    @DeleteMapping("/deleteById")
    @ApiOperation(value = "根据id删除配套信息")
    public Result deleteById(Long id){
        facilityService.deleteById(id);
        return Result.ok();
    }
}
